﻿// Copyright © Olaf Kober, 2013-05

using System;
using System.Linq;
using Amarok.Agents;


namespace $rootnamespace$
{
	/// <summary>
	/// This type implements the application-specific agent runtime.
	/// </summary>
	public sealed class $fileinputname$Runtime : Runtime<MyEnvironment>
	{
		#region ++ Public Interface ++
		
		/// <summary>
		/// Initializes a new instance.
		/// </summary>
		public $fileinputname$Runtime()
		{
		}
		
		#endregion

		#region ## Overridable Methods ##

		/// <summary>
		/// This method is called once during agent runtime startup to create an instance of the agent runtime 
		/// environment, which will be provided to all subsystems and agents hosted in this agent runtime. The
		/// method can be overridden in derived types to provide agents and subsystems with a custom agent runtime 
		/// environment that contains other common services that runtime and message bus.
		/// </summary>
		/// 
		/// <param name="runtime">
		/// A reference to the agent runtime, which must be passed to agent runtime environment, which 
		/// will be returned.</param>
		/// <param name="messageBus">
		/// A reference to the message bus, which must be passed to the agent runtime environment, which
		/// will be returned.</param>
		/// 
		/// <returns>
		/// A reference to the newly created agent runtime environment.</returns>
		protected override MyEnvironment CreateEnvironment(IRuntime runtime, IMessageBus messageBus)
		{
			return new MyEnvironment(
				runtime, 
				messageBus);
		}
		

		/// <summary>
		/// An overrideable method that allows derived types to implement custom startup logic. The startup
		/// method is called once after the message bus and runtime environment has been created.
		/// 
		/// This method is guaranteed to be called once.
		/// </summary>
		protected override void OnStartup()
		{
			base.OnStartup();
		}

		/// <summary>
		/// An overrideable method that allows derived types to implement custom cleanup logic. The cleanup
		/// method is called at last after the runtime run to completion.
		/// 
		/// This method is guaranteed to be called once.
		/// </summary>
		protected override void OnCleanup()
		{
			base.OnCleanup();
		}

		#endregion

	}
}
